
const Promise = require('./src/2.promise.js');
// 当调用then方法时，promise的状态可能是pending，此时需要把成功和失败回调先存起来，等待状态变更后，再执行onFil
let promise = new Promise((resolve, reject) => {
    setTimeout(() => {
        resolve('成功');
    }, 2000)
})

promise.then((val) => {
    console.log('success', val);
}, (reason) => {
    console.log('err', reason);
})
